#ifndef TWEAK_BAR_H
#define TWEAK_BAR_H

#include "OpenGL.h"
#include "AntTweakBar.h"
#include "Light.h"
#include "Fog.h"
#include "KeyBoardControl.h"
float g_LightDirection[] = { -0.57735f, -0.57735f, -0.57735f };
class TweakBar{
public:
	TwBar *twBarLightAndFog;
	TwBar *twBarControls;

	void setupLightTweakBar(Light &Light0, Light &Light1, Light &Light2, Light &Light3);
	void setupControls(KeyBoardControl &kControl);
	void setupFogTweakBar(Fog &fog);
};
void TweakBar::setupControls(KeyBoardControl &kControl){
	twBarControls = TwNewBar("Controls");
	TwAddVarRO(twBarControls, "TurnLeft", TW_TYPE_INT32, &(kControl.turnLeftKey), " label='TurnLeft' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "TurnRight", TW_TYPE_INT32, &(kControl.turnRightKey), " label='TurnRight' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "Accelerate", TW_TYPE_INT32, &(kControl.accelerateKey), " label='Accelerate' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "Decelerate", TW_TYPE_INT32, &(kControl.decellerateKey), " label='Decelerate' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "FireLeftCannon", TW_TYPE_INT32, &(kControl.leftCannonFireKey), " label='FireLeftCannon' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "FireRightCannon", TW_TYPE_INT32, &(kControl.rightCannonFireKey), " label='FireRightCannon' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "ChangeCamera", TW_TYPE_INT32, &(kControl.changeCameraKey), " label='ChangeCamera' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "IncreaseFirePower", TW_TYPE_INT32, &(kControl.increasePower), " label='InceaseFirePower' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "DecreaseFirePower", TW_TYPE_INT32, &(kControl.decreasePower), " label='DecreaseFirePower' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "CameraTurnLeft", TW_TYPE_INT32, &(kControl.cameraTurnLeft), " label='CameraTurnLeft' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "CameraRightLeft", TW_TYPE_INT32, &(kControl.cameraTurnRight), " label='CameraRightLeft' group='ASDF_KeyLayout' ");
	TwAddVarRO(twBarControls, "SniperShoot", TW_TYPE_INT32, &(kControl.sniperShootKey), " label='SniperShoot' group='ASDF_KeyLayout' ");
	//TwAddVarRO(twBarControls, "", TW_TYPE_INT32, &(kControl.Key), " label='' group='ASDF_KeyLayout' ");

}
void TweakBar::setupLightTweakBar(Light &Light0, Light &Light1, Light &Light2, Light &Light3){
	twBarLightAndFog = TwNewBar("Lighting");
	//cyclone::Quaternion g_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
	//TwAddVarRW(twBarLightAndFog, "ObjRotation", TW_TYPE_QUAT4F, &g_Rotation, " label='Object rotation' open help='Change the object orientation.' ");
	TwAddVarCB(twBarLightAndFog, "GlobalLight", TW_TYPE_BOOL32, GlobalLight::SetGlobalLightOnOffCB, GlobalLight::GetGlobalLightOnOffCB, &Light0, 
               " label='GlobalLight' help='Toggle GlobalLight' ");
	TwAddVarRW(twBarLightAndFog, "AmbientGlobal", TW_TYPE_COLOR4F, &(GlobalLight::envAmbient), "label='Ambient' group='GlobalLight Attributes' ");
	//GlobalLight settings
	//Light0 Settings
	TwAddVarCB(twBarLightAndFog, "Light0", TW_TYPE_BOOL32, Light::SetLightOnOffCB, Light::GetLightOnOffCB, &Light0, 
               " label='Light0' help='Toggle Light0' ");
	//TwAddVarCB(twBarLightAndFog, "PositionL0", TW_TYPE_DIR3F, Light::SetPositionCB, Light::GetPositionCB, &Light0, 
    //           " label='Position' help='Set Light Position' group='Light0 Attributes' ");
	TwAddVarRW(twBarLightAndFog, "AmbientL0", TW_TYPE_COLOR4F, &(Light0.ambient),   " label='Ambient' group='Light0 Attributes' ");
	TwAddVarRW(twBarLightAndFog, "DiffuseL0", TW_TYPE_COLOR4F, &(Light0.diffuse),   " label='Diffuse'  group='Light0 Attributes' ");
	TwAddVarRW(twBarLightAndFog, "SpecularL0", TW_TYPE_COLOR4F, &(Light0.specular), " label='Specular' group='Light0 Attributes' ");
	TwAddVarRW(twBarLightAndFog, "LightDir", TW_TYPE_DIR3F, &(Light0.position),//&g_LightDirection, 
               " label='Light direction' help='Change the light direction.' group='Light0 Attributes' ");

}

void TweakBar::setupFogTweakBar(Fog &fog){
	TwAddVarCB(twBarLightAndFog, "Fog", TW_TYPE_BOOL32, Fog::SetFogOnOffCB, Fog::GetFogOnOffCB, &fog, 
               " label='Fog' help='Toggle Fog' ");
	TwAddVarRW(twBarLightAndFog, "fogColor", TW_TYPE_COLOR4F, &fog.fogColor, 
               " label='Fog color' alpha help='Color and transparency of the Fog.' group='Fog Attributes' ");
	TwAddVarRW(twBarLightAndFog, "fogDensity", TW_TYPE_FLOAT, &fog.fogDensity, 
               " label='Fog Density'  min=0 max=1 step=0.01 help='Density of the Fog.' group='Fog Attributes' ");
}

void GLFWCALL OnMousePos(int mouseX, int mouseY){  // your callback function called by GLFW when mouse has moved
  if( !TwEventMousePosGLFW(mouseX, mouseY) )  // send event to AntTweakBar
    { // event has not been handled by AntTweakBar
      // your code here to handle the event
      // ...
    }
  }
void GLFWCALL OnMouseButton(int glfwButton, int glfwAction){  // your callback function called by GLFW when mouse has moved
    if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) )  // send event to AntTweakBar
    { // event has not been handled by AntTweakBar
      // your code here to handle the event
      // ...
    }
  }
VOID GLFWCALL OnMouseWheel(int pos){  // your callback function called by GLFW when mouse has moved
    if( !TwEventMouseWheelGLFW(pos) ) { // send event to AntTweakBar
      // event has not been handled by AntTweakBar
      // your code here to handle the event
      // ...
    }
  }


#endif